package com.xckj.teacher.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.xckj.teacher.R;

/**
 * @Author: ChenYao
 * @Describe: 协议的Dialog
 * @Date: 2024/6/26 22:30
 */
public class ProtocolDialog extends Dialog {
    private TextView tvUseProtocol;
    private TextView tvPrivacyProtocol;
    private TextView tvChildrenProtocol;
    private TextView tvNotAgree;
    private TextView tvAgree;
    private OnNotAgreeClickListener notAgreeClickListener;
    private OnAgreeClickListener agreeClickListener;
    private OnLookProtocolClickListenerOne lookProtocolClickListenerOne;
    private OnLookProtocolClickListenerTwo lookProtocolClickListenerTwo;
    private OnLookProtocolClickListenerThree lookProtocolClickListenerThree;


    public ProtocolDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    public void setNotAgreeClickListener(OnNotAgreeClickListener notAgreeClickListener) {
        this.notAgreeClickListener = notAgreeClickListener;
    }

    public void setAgreeClickListener(OnAgreeClickListener agreeClickListener) {
        this.agreeClickListener = agreeClickListener;
    }

    public void setLookProtocolClickListenerOne(OnLookProtocolClickListenerOne lookProtocolClickListenerOne) {
        this.lookProtocolClickListenerOne = lookProtocolClickListenerOne;
    }

    public void setLookProtocolClickListenerTwo(OnLookProtocolClickListenerTwo lookProtocolClickListenerTwo) {
        this.lookProtocolClickListenerTwo = lookProtocolClickListenerTwo;
    }

    public void setLookProtocolClickListenerThree(OnLookProtocolClickListenerThree lookProtocolClickListenerThree) {
        this.lookProtocolClickListenerThree = lookProtocolClickListenerThree;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_protocol);
        setCanceledOnTouchOutside(false);
        setCancelable(false);
        initView();
        setListener();
    }

    private void initView() {
        tvUseProtocol = findViewById(R.id.tv_use_protocol);
        tvPrivacyProtocol = findViewById(R.id.tv_privacy_protocol);
        tvChildrenProtocol = findViewById(R.id.tv_children_protocol);
        tvNotAgree = findViewById(R.id.tv_not_agree);
        tvAgree = findViewById(R.id.tv_agree);
    }

    private void setListener() {
        tvNotAgree.setOnClickListener(view -> {
            if (null != notAgreeClickListener) {
                notAgreeClickListener.onNotAgreeClick();
            }
        });
        tvAgree.setOnClickListener(view -> {
            if (null != agreeClickListener) {
                agreeClickListener.onAgreeClick();
            }
        });
        tvUseProtocol.setOnClickListener(view -> {
            if (null != lookProtocolClickListenerOne) {
                lookProtocolClickListenerOne.onLookProtocolClick();
            }
        });
        tvPrivacyProtocol.setOnClickListener(view -> {
            if (null != lookProtocolClickListenerTwo) {
                lookProtocolClickListenerTwo.onLookProtocolClick();
            }
        });
        tvChildrenProtocol.setOnClickListener(view -> {
            if (null != lookProtocolClickListenerThree) {
                lookProtocolClickListenerThree.onLookProtocolClick();
            }
        });
    }

    public interface OnNotAgreeClickListener {
        /**
         * 不同意
         */
        void onNotAgreeClick();
    }

    public interface OnAgreeClickListener {
        /**
         * 同意
         */
        void onAgreeClick();
    }

    public interface OnLookProtocolClickListenerOne {
        /**
         * 查看协议
         */
        void onLookProtocolClick();
    }

    public interface OnLookProtocolClickListenerTwo {
        /**
         * 查看协议
         */
        void onLookProtocolClick();
    }

    public interface OnLookProtocolClickListenerThree {
        /**
         * 查看协议
         */
        void onLookProtocolClick();
    }
}
